/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.gianluca.sagrafx.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author eginfer
 */
@Entity
@Table(name = "pietanze")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Pietanze.findAll", query = "SELECT p FROM Pietanze p"),
    @NamedQuery(name = "Pietanze.findById", query = "SELECT p FROM Pietanze p WHERE p.id = :id"),
    @NamedQuery(name = "Pietanze.findByNome", query = "SELECT p FROM Pietanze p WHERE p.nome = :nome"),
    @NamedQuery(name = "Pietanze.findByCosto", query = "SELECT p FROM Pietanze p WHERE p.costo = :costo"),
    @NamedQuery(name = "Pietanze.findByVenduti", query = "SELECT p FROM Pietanze p WHERE p.venduti = :venduti")})
public class Pietanze implements Serializable {
    @OneToMany(mappedBy = "idPietanza")
    private Collection<Ordini> ordiniCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "nome")
    private String nome;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @Column(name = "costo")
    private BigDecimal costo;
    @Basic(optional = false)
    @Column(name = "venduti")
    private int venduti;

    public Pietanze() {
    }

    public Pietanze(Integer id) {
        this.id = id;
    }

    public Pietanze(Integer id, String nome, BigDecimal costo, int venduti) {
        this.id = id;
        this.nome = nome;
        this.costo = costo;
        this.venduti = venduti;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public BigDecimal getCosto() {
        return costo;
    }

    public void setCosto(BigDecimal costo) {
        this.costo = costo;
    }

    public int getVenduti() {
        return venduti;
    }

    public void setVenduti(int venduti) {
        this.venduti = venduti;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pietanze)) {
            return false;
        }
        Pietanze other = (Pietanze) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.gianluca.sagrafx.entities.Pietanze[ id=" + id + " ]";
    }

    @XmlTransient
    public Collection<Ordini> getOrdiniCollection() {
        return ordiniCollection;
    }

    public void setOrdiniCollection(Collection<Ordini> ordiniCollection) {
        this.ordiniCollection = ordiniCollection;
    }
    
}
